<?php
session_start();
require('../conn.php');
require('../functions.php');
require('admin.php');
if ($_POST) {
    $name = guolv($_POST['username']);
    $head = guolv($_POST['head']);
    $phone = guolv($_POST['phone']);
	$sex = guolv($_POST['sex']);
    $userinfo = array(
        'phone' => $phone,
        'password' => 111111,
        'head' => $head,
        'name' => $name,
        'sex' => $sex,
        'isrobot' => 1
    );
//    echo arr2s($userinfo);exit;
    $userSql = "insert into `user`".arr2s($userinfo);
    $mysql->execute($userSql);
    $id = mysql_insert_id();
    $role = array(
        'user_id' => $id,
        'authority_name' => 'ROLE_USER'
    );
    $roleSql = "insert into `jhi_user_authority`".arr2s($role);
    $res = $mysql->execute($roleSql);
    if($res){
        echo "<script>alert('添加成功');location.href='adduser.php'</script>";
        exit;
    }

} ?>

<?php include('head.php') ?>
<link rel="stylesheet" href="../editor/themes/default/default.css"/>
<link rel="stylesheet" href="../editor/plugins/code/prettify.css"/>
<script src="<?php echo $jquerysite ?>" type="text/javascript"></script>
<script charset="utf-8" src="../editor/kindeditor.js"></script>
<script charset="utf-8" src="../editor/lang/zh_CN.js"></script>
<script charset="utf-8" src="../editor/plugins/code/prettify.js"></script>
<div class="container-fluid">

    <div class="row-fluid">
        <?php
        include('left.php'); ?>
        <div class="span10">
            <h1 class="page-title">用户添加</h1>
            <div class="well">
                <ul class="nav nav-tabs">
                    <li class="active"><a href="#home" data-toggle="tab">设置</a></li>
                </ul>
                <div id="myTabContent" class="tab-content">
                    <div class="tab-pane active in" id="home">
                        <form id="tab" action="" method="post">
                            <label>用户名</label>
                            <input name="username" type="text" style="width:300px" name="name" value="">
                            <label>电话</label>
                            <input name="phone" type="text" style="width:300px" name="name" value="">
                            <label>用户头像</label>
                            <input name="head" type="text" style="width:300px" name="type" value="">
                            <label>性别</label>
                            <select name="sex">
                            	<option value="1">1</option>
                            	<option value="2">2</option>
                            </select>
                            <label></label>
                            <button class="btn btn-primary"><i class="icon-save"></i> 添加</button>
                        </form>
                    </div>
                </div>

            </div>
        </div>
    </div>


</div>

<footer>
    <hr>

    <p class="pull-right"><!--power by right--></p>


    <p><!--power by --></p>
</footer>


<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="lib/bootstrap/js/bootstrap.js"></script>


</body>
</html>